<?php
 jimport('joomla.application.component.view');
 // Load the view framework
 if(!class_exists('VmView'))require(JPATH_COMPONENT.DS.'helpers'.DS.'vmview.php');
 jimport('joomla.html.pane');
class svViewDonviquanly extends JView
{
	function display()
	{
		$id=JRequest::getInt('id');
		if($id==0)
		{
			$this->_default();
		}
		else
		{
			$this->_chitiet($id);
		}
		parent::display();
	}
	//-------------------screen-----------------------------------
	// hien thi tat ca cac giai dau
	function _default()
	{
		$model=$this->getModel('donviquanly');
		// lay du lieu can cho vao layout
		$donviList=$model->getAllDonvi();
		// set layout
		$this->assignRef('objectList', $donviList);
		$this->setLayout('default');
	}
	function _chitiet($id)
	{
		$model=$this->getModel('donviquanly');
		// lay du lieu
		$donvi=$model->getDonviByID($id);
		$phongbanList=$model->getPhongbanByDonvi($id);
		$truongdonvi=$model->getTruongdonvi($id);
		$phodonvi=$model->getPhodonvi($id);
		// set layout
		$this->assignRef('donvi', $donvi);
		$this->assignRef('phongbanList', $phongbanList);
		$this->assignRef('truongdonvi', $truongdonvi);
		$this->assignRef('phodonvi', $phodonvi);
		$this->setLayout('chitiet');
	}
	
	
}
?>